package com.ktgj.customer.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.customer.domain.ClaimDelayinsuranceImage;
import com.ktgj.customer.service.IClaimDelayinsuranceImageService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 保险理赔图片Controller
 * 
 * @author ruoyi
 * @date 2022-06-17
 */
@RestController
@RequestMapping("/image")
public class ClaimDelayinsuranceImageController extends BaseController
{
    @Autowired
    private IClaimDelayinsuranceImageService claimDelayinsuranceImageService;

    /**
     * 查询保险理赔图片列表
     */
    @PreAuthorize(hasPermi = "system:image:list")
    @GetMapping("/list")
    public TableDataInfo list(ClaimDelayinsuranceImage claimDelayinsuranceImage)
    {
        startPage();
        List<ClaimDelayinsuranceImage> list = claimDelayinsuranceImageService.selectClaimDelayinsuranceImageList(claimDelayinsuranceImage);
        return getDataTable(list);
    }

    /**
     * 导出保险理赔图片列表
     */
    @PreAuthorize(hasPermi = "system:image:export")
    @Log(title = "保险理赔图片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ClaimDelayinsuranceImage claimDelayinsuranceImage) throws IOException
    {
        List<ClaimDelayinsuranceImage> list = claimDelayinsuranceImageService.selectClaimDelayinsuranceImageList(claimDelayinsuranceImage);
        ExcelUtil<ClaimDelayinsuranceImage> util = new ExcelUtil<ClaimDelayinsuranceImage>(ClaimDelayinsuranceImage.class);
        util.exportExcel(response, list, "保险理赔图片数据");
    }

    /**
     * 获取保险理赔图片详细信息
     */
    @PreAuthorize(hasPermi = "system:image:query")
    @GetMapping(value = "/{imageId}")
    public AjaxResult getInfo(@PathVariable("imageId") Long imageId)
    {
        return AjaxResult.success(claimDelayinsuranceImageService.selectClaimDelayinsuranceImageById(imageId));
    }

    /**
     * 新增保险理赔图片
     */
    @PreAuthorize(hasPermi = "system:image:add")
    @Log(title = "保险理赔图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ClaimDelayinsuranceImage claimDelayinsuranceImage)
    {
        return toAjax(claimDelayinsuranceImageService.insertClaimDelayinsuranceImage(claimDelayinsuranceImage));
    }

    /**
     * 修改保险理赔图片
     */
    @PreAuthorize(hasPermi = "system:image:edit")
    @Log(title = "保险理赔图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ClaimDelayinsuranceImage claimDelayinsuranceImage)
    {
        return toAjax(claimDelayinsuranceImageService.updateClaimDelayinsuranceImage(claimDelayinsuranceImage));
    }

    /**
     * 删除保险理赔图片
     */
    @PreAuthorize(hasPermi = "system:image:remove")
    @Log(title = "保险理赔图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{imageIds}")
    public AjaxResult remove(@PathVariable Long[] imageIds)
    {
        return toAjax(claimDelayinsuranceImageService.deleteClaimDelayinsuranceImageByIds(imageIds));
    }
}
